
#include <iomanip>
#include <LEDA/core/string.h>
#include <LEDA/numbers/integer_matrix.h>
#include <LEDA/numbers/integer_vector.h>
#include<LEDA/core/array.h>
#include <LEDA/system/error.h>
#include <iostream>
#include <cstdlib>
#include <exception>

using leda::string;
using leda::leda_exception;
using std::cin;
using std::cout;
using std::endl;
using std::setw;
using std::bad_exception;
using std::exception;

//#ifndef   _MATRIX_H
 // #define   _MATRIX_H
//using namespace std;
using namespace leda;




class MatrixUtil 
{		
public :
	MatrixUtil();
	MatrixUtil(char* strInput);
	~MatrixUtil();
	void parserRandom(char * strInput);
	int Recursive_Matrix(int i, int j);
	void MatrixChainOrder(int size);
	int OptimizeCost();
	int NormalCost();
	void Print_M();
	void Print_M1();
	
	static const int cSIZEMAX = 1000;
	string PrintParenthese(int a, int b, int i, int j);	
	integer_matrix matrix_chain_multiply();
	integer_matrix chain_multiply( array<integer_matrix> v, int i, int j);
	int S[cSIZEMAX+1][cSIZEMAX+1];
	integer_matrix  matrix_result;
	int P[cSIZEMAX] ;
	int M[cSIZEMAX+1][cSIZEMAX+1];
	string alpha;
	void processCommand(string text);
	void parseInput(string text,int * sequenceNumber);
	void removeSpaces(char * text);
	bool getValues(int numOfEntries, string input, int *entries,int *sequenceNumber);
	void getMatrix(int rows, int cols, int * entries,integer_matrix * matrix);
	string retStringFromMatrixP();

	int iSIZE ;
	int iErrorCode ;
	int iSequenceNumber;/* sequence la moi matrix*/
	array<integer_matrix> matrixVector;
	bool errorPresent;

	static const int TheSizeNotFitable = -2;
	static const int InputStringIsNull = -10;
	static const int MissingKeywordMatrixForEntry = -11;
	static const int MissingOpeningParenthesisForMatrix = -12;
	static const int MissingClosingParenthesisForMatrix = -13;
	static const int MissingTheFirstComma = -14;
	static const int RowCannotBe0ForMatrix = -15;
	static const int MissingSecondComma = -16;
	static const int ColumnCannotBe0ForMatrix = -17;
	static const int MissingOpeningBracketForMatrix = -18;
	static const int MissingClosingBracketForMatrix = -19;
	static const int TooFewEntriesForMatrix = -20;
	static const int SyntaxErrorInExpressionAfterMatrix = -21;
	static const int MissingAtTheCol = -22;
	static const int MissingAtTheRow = -23;
	static const int TheNumberInMatrixError = -24;
	
	static const int MAX = 999999;	

	

};

//#endif

